package com.fmsz.xmly.adapters.classify.tag;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.fmsz.xmly.entitys.classify.tag.ClassifyTagEntity;
import com.fmsz.xmly.fragments.findfgts.ClassifyTagBaseFragment;

import java.util.List;

/**
 * Created by Administrator on 2016/12/12.
 */

public class ClassifyTagPagerAdapter extends FragmentPagerAdapter {

    private List<ClassifyTagEntity.TagEntity.TagListEntity> titles;
    private String categoryId;

    public ClassifyTagPagerAdapter(FragmentManager fm,List<ClassifyTagEntity.TagEntity.TagListEntity> titles,String categoryId) {
        super(fm);
        this.titles = titles;
        this.categoryId = categoryId;
    }

    @Override
    public Fragment getItem(int position) {
        if (position==0) {
            return  ClassifyTagBaseFragment.newInstance(titles.get(position).getTname(),categoryId,ClassifyTagBaseFragment.RECOMMEND);
        }
        return ClassifyTagBaseFragment.newInstance(titles.get(position).getTname(),categoryId,ClassifyTagBaseFragment.NOMAL);
    }

    @Override
    public int getCount() {
        return titles.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles.get(position).getTname();
    }
}
